﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Abp.AspNetCore.Configuration;
using Abp.Configuration.Startup;
using Abp.Modules;
using Abp.Reflection.Extensions;

namespace GCT.Foundation
{
    [DependsOn(
        typeof(GCTSharedWebCoreModule),
        typeof(FoundationTemplateApplicationModule),
        typeof(FoundationTemplateEntityFrameworkCoreModule)
    )]
    public class FoundationTemplateWebCoreModule : AbpModule
    {
        public override void PreInitialize()
        {
            // 注册动态webapi
            Configuration.Modules.AbpAspNetCore()
                .CreateControllersForAppServices(
                    typeof(FoundationTemplateApplicationModule).GetAssembly()
                );
        }

        public override void Initialize()
        {
            // 注册程序集中的依赖
            IocManager.RegisterAssemblyByConvention(GetType().GetAssembly());
            // 只有在开发环境下才会把错误发送到客户端
            Configuration.Modules.AbpWebCommon().SendAllExceptionsToClients = true;
        }
    }
}
